home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 22 / Cream of the Crop 22.iso / bbs / pad321.zip / STRIPNUM.MH < prev    next >
Text File  |  1996-08-21  |  793b  |  32 lines

  1. #ifndef __STRIPNUM_MH
  2. #define __STRIPNUM_MH
  3.  
  4. // stripNonNumeric removes all non-numeric characters from the string.
  5. // Returns the number of numeric characters found in the string.
  6. // The original string is modified.
  7.  
  8. int stripNonNumeric (Ref string: s) {
  9.   int: sidx, tidx;
  10.  
  11.   tidx := 1;
  12.   for (sidx := 1; sidx  <= strlen (s); sidx := sidx + 1) {
  13.     if ((s [sidx] >= '0') and (s [sidx] <= '9')) {
  14.       s [tidx] := s [sidx];
  15.       tidx := tidx + 1;
  16.       };
  17.     };
  18.   s := substr (s,1,tidx-1);
  19.   return tidx-1;
  20.   }
  21.  
  22. // stripNonNumericf removes all non-numeric characters from a string
  23. // without modifying the original string. The new string is returned
  24. // by the function.
  25.  
  26. string stripNonNumericf (string: s) {
  27.   stripNonNumeric (s);
  28.   return s;
  29.   }
  30.  
  31. #endif
  32.